// http://www.pokerprolabs.com/topshark/topshark.aspx
// Java Script for search requests processing

function SearchPlayer()
{
    var a = document.getElementById(PlayerNameTextBox);
    a.value = a.value.replace(/(^\s*)|(\s*$)/g, "");
    if (a.value.length != 0 && a.className.indexOf("playerNameTextBoxWatermark") == -1) {
        var c = document.getElementById("updateProgress");
        if (!HasAttribute(c, "counter") || !parseInt(c.getAttribute("counter"))) {
            c.style.display = "";
            c.setAttribute("counter", "1")
        }
        else {
            c.setAttribute("counter", (parseInt(c.getAttribute("counter")) + 1).toString())
        }
        var b = encodeURIComponent(encodeURIComponent(encodeURIComponent(a.value.replace(/</g, "%3c").replace(/>/g, "%3e"))));
        createRequest(GetSearchUrl("playername", b, document.getElementById(PokerClientsDropDownList).value), OnSearchComplete, "OnSearchComplete(null)")
    }
}
function WebRequest(a, b, c) {
    this.url = a;
    this.handler = b;
    this.handlertext = c
}
var WebRequestQueue = new Array();
var WebRequestStatus = 0;
function ProcessNextWebRequest() {
    if (!WebRequestStatus && WebRequestQueue.length) {
        WebRequestStatus++;
        var a = WebRequestQueue.shift();
        SendWebRequest(a.url, a.handler, a.handlertext)
    }
    window.setTimeout(ProcessNextWebRequest, 100)
}
var ie60 = null;
function IsIE60() {
    if (ie60 == null) {
        ie60 = false;
        if (document.all) {
            var c = window.navigator.userAgent.indexOf("MSIE");
            if (c != -1) {
                try {
                    var b = parseInt(window.navigator.userAgent.substr(c + "MSIE".length).replace(/(^\s*)|(\s*$)/g, ""));
                    ie60 = b < 7
                } catch(a) {
                }
            }
        }
    }
    return ie60
}
function createRequest(a, c, d) {
    a += "&sessionid=" + getSessionId();
    if (IsIE60() && WebRequestStatus) {
        var b = new WebRequest(a, c, d);
        WebRequestQueue.push(b)
    } else {
        WebRequestStatus++;
        SendWebRequest(a, c, d)
    }
}
var RequestHandler = null;
function OnRequestLoad(b) {
    var a;
    if (b) {
        a = b.currentTarget
    } else {
        if (document.all) {
            a = window.event.srcElement
        }
    }
    if (a && a.src.toLowerCase() != "about:blank") {
        RequestHandler(b)
    }
}
var RequestNumber = 0;
function SendWebRequest(b, d, f) {
    var e = IsIE60() ? "request" : "request" + (RequestId++).toString();
    var c = new Date();
    b += "&request=" + (RequestNumber++).toString() + "&date=" + c.getFullYear().toString() + "-" + (c.getMonth() + 1).toString() + "-" + c.getDate().toString() + "T" + c.getHours().toString() + ":" + c.getMinutes().toString() + ":" + c.getSeconds().toString() + "." + c.getMilliseconds().toString();
    if (IsIE60()) {
        var a = document.getElementById(document.all ? "requestIE" : "requestFF");
        RequestHandler = d;
        a.src = b
    } else {
        if (document.all) {
            var a = document.createElement("<iframe id='" + e + "' name='" + e + "' width='0' height='0' frameborder='0' scrolling='no' onload='" + f + "' src='" + b + "' ></iframe>")
        } else {
            var a = document.createElement("iframe");
            a.frameBorder = "0";
            a.height = "0";
            a.width = "0";
            a.scrolling = "no";
            a.name = e;
            a.src = b;
            a.id = e;
            a.onload = d
        }
        document.body.appendChild(a)
    }
}
function getStatisticsTable(b) {
    var a;
    switch (b) {case 1:a = "MTT";break;case 2:a = "SNG";break;case 4:a = "HUP";break
    }
    return document.getElementById(a + "StatisticsGridView")
}
function NextPage(e, h) {
    var k = document.getElementById(e);
    var g = false;
    var f = PageSize;
    var c = getElementByTagName(k.rows[k.rows.length - 1].cells[0], "TABLE").rows[0];
    var b = c.getElementsByTagName("A");
    var a = getElementByTagName(c, "SELECT");
    var d = h ? 2 : 1;
    if (!HasAttribute(b[2], "disabled") || !bool(b[2].getAttribute("disabled"))) {
        for (i = 1; i < k.rows.length - d && f; i += d) {
            if (!g) {
                g = k.rows[i].style.display != "none"
            }
            if (g) {
                if (k.rows[i].style.display != "none") {
                    k.rows[i].style.display = "none";
                    if (h) {
                        k.rows[i + 1].setAttribute("display", k.rows[i + 1].style.display);
                        k.rows[i + 1].style.display = "none"
                    }
                } else {
                    k.rows[i].style.display = "";
                    if (h) {
                        k.rows[i + 1].style.display = HasAttribute(k.rows[i + 1], "display") ? k.rows[i + 1].getAttribute("display") : "none"
                    }
                    f--
                }
            }
        }
        a.selectedIndex = Math.ceil((i / d - 1) / PageSize) - 1;
        if (i >= k.rows.length - d) {
            b[2].setAttribute("disabled", true);
            b[3].setAttribute("disabled", true)
        }
    }
    b[0].setAttribute("disabled", false);
    b[1].setAttribute("disabled", false)
}
function bool(a) {
    return a.toString().toLowerCase() == "true" ? true : false
}
function PrevPage(e, h) {
    var k = document.getElementById(e);
    var g = false;
    var f = PageSize;
    var c = getElementByTagName(k.rows[k.rows.length - 1].cells[0], "TABLE").rows[0];
    var b = c.getElementsByTagName("A");
    var a = getElementByTagName(c, "SELECT");
    var d = h ? 2 : 1;
    if (!HasAttribute(b[1], "disabled") || !bool(b[1].getAttribute("disabled"))) {
        for (i = k.rows.length - d - 1; i > 0 && f; i -= d) {
            if (!g) {
                g = k.rows[i].style.display != "none"
            }
            if (g) {
                if (k.rows[i].style.display != "none") {
                    k.rows[i].style.display = "none";
                    if (h) {
                        k.rows[i + 1].setAttribute("display", k.rows[i + 1].style.display);
                        k.rows[i + 1].style.display = "none"
                    }
                } else {
                    k.rows[i].style.display = "";
                    if (h) {
                        k.rows[i + 1].style.display = HasAttribute(k.rows[i + 1], "display") ? k.rows[i + 1].getAttribute("display") : "none"
                    }
                    f--
                }
            }
        }
        a.selectedIndex = Math.ceil((i / d + 1) / PageSize) - 1;
        if (i <= 0) {
            b[0].setAttribute("disabled", true);
            b[1].setAttribute("disabled", true)
        }
    }
    b[2].setAttribute("disabled", false);
    b[3].setAttribute("disabled", false)
}
function FirstPage(e, h) {
    var k = document.getElementById(e);
    var g = false;
    var f = PageSize;
    var c = getElementByTagName(k.rows[k.rows.length - 1].cells[0], "TABLE").rows[0];
    var b = c.getElementsByTagName("A");
    var a = getElementByTagName(c, "SELECT");
    var d = h ? 2 : 1;
    if (!HasAttribute(b[0], "disabled") || !bool(b[0].getAttribute("disabled"))) {
        for (i = 1; i < k.rows.length - d && f; i += d) {
            k.rows[i].style.display = "";
            if (h) {
                k.rows[i + 1].style.display = HasAttribute(k.rows[i + 1], "display") ? k.rows[i + 1].getAttribute("display") : "none"
            }
            f--
        }
        for (; i < k.rows.length - d; i += d) {
            if (!g) {
                g = k.rows[i].style.display != "none"
            }
            if (g) {
                if (k.rows[i].style.display != "none") {
                    k.rows[i].style.display = "none";
                    if (h) {
                        k.rows[i + 1].setAttribute("display", k.rows[i + 1].style.display);
                        k.rows[i + 1].style.display = "none"
                    }
                } else {
                    break
                }
            }
        }
        a.selectedIndex = 0;
        b[0].setAttribute("disabled", true);
        b[1].setAttribute("disabled", true)
    }
    b[2].setAttribute("disabled", false);
    b[3].setAttribute("disabled", false)
}
function qSortI(b) {
    var f,c;
    var a,l;
    var d = [],e = [];
    var m = 1;
    var g;
    var h;
    var k;
    d[1] = 0;
    e[1] = b - 1;
    do{
        a = d[m];
        l = e[m];
        m--;
        do{
            g = (a + l) >> 1;
            f = a;
            c = l;
            h = sortData[g].key;
            do{
                while (sortData[f].key < h) {
                    f++
                }
                while (h < sortData[c].key) {
                    c--
                }
                if (f <= c) {
                    k = sortData[f];
                    sortData[f] = sortData[c];
                    sortData[c] = k;
                    f++;
                    c--
                }
            } while (f <= c);
            if (f < g) {
                if (f < l) {
                    m++;
                    d[m] = f;
                    e[m] = l
                }
                l = c
            } else {
                if (c > a) {
                    m++;
                    d[m] = a;
                    e[m] = c
                }
                a = f
            }
        } while (a < l)
    } while (m != 0)
}
var sortData = null;
function compare(d, c) {
    return sortData[d].key < sortData[c].key ? -1 : (sortData[d].key == sortData[c].key ? 0 : 1)
}
function GoToPage(h, m) {
    var n = document.getElementById(h);
    var l = false;
    var k = PageSize;
    var f = getElementByTagName(n.rows[n.rows.length - 1].cells[0], "TABLE").rows[0];
    var d = f.getElementsByTagName("A");
    var b = getElementByTagName(f, "SELECT");
    var c = -1;
    var g = m ? 2 : 1;
    try {
        c = parseInt(b.value)
    } catch(a) {
    }
    if (c > 0 && c <= Math.ceil((n.rows.length - 2) / g / PageSize)) {
        for (i = 1; i < n.rows.length - g; i += g) {
            if (!l) {
                l = n.rows[i].style.display != "none"
            }
            if (l) {
                if (n.rows[i].style.display != "none") {
                    n.rows[i].style.display = "none";
                    if (m) {
                        n.rows[i + 1].setAttribute("display", n.rows[i + 1].style.display);
                        n.rows[i + 1].style.display = "none"
                    }
                } else {
                    break
                }
            }
        }
        for (i = (c - 1) * PageSize * g + 1; i < n.rows.length - g && k; i += g) {
            n.rows[i].style.display = "";
            if (m) {
                n.rows[i + 1].style.display = HasAttribute(n.rows[i + 1], "display") ? n.rows[i + 1].getAttribute("display") : "none"
            }
            k--
        }
        d[0].setAttribute("disabled", false);
        d[1].setAttribute("disabled", false);
        d[2].setAttribute("disabled", false);
        d[3].setAttribute("disabled", false);
        if (c == 1) {
            d[0].setAttribute("disabled", true);
            d[1].setAttribute("disabled", true)
        } else {
            if (c == Math.ceil((n.rows.length - 2) / g / PageSize)) {
                d[2].setAttribute("disabled", true);
                d[3].setAttribute("disabled", true)
            }
        }
    } else {
        alert("Page number is out of range.")
    }
}
function LastPage(e, h) {
    var k = document.getElementById(e);
    var g = false;
    var c = getElementByTagName(k.rows[k.rows.length - 1].cells[0], "TABLE").rows[0];
    var b = c.getElementsByTagName("A");
    var a = getElementByTagName(c, "SELECT");
    var d = h ? 2 : 1;
    if (!HasAttribute(b[3], "disabled") || !bool(b[3].getAttribute("disabled"))) {
        var f = ((k.rows.length - 2) / d) % PageSize;
        if (!f) {
            f = PageSize
        }
        for (i = k.rows.length - d - 1; i > 0 && f; i -= d) {
            k.rows[i].style.display = "";
            if (h) {
                k.rows[i + 1].style.display = HasAttribute(k.rows[i + 1], "display") ? k.rows[i + 1].getAttribute("display") : "none"
            }
            f--
        }
        for (; i > 0; i -= d) {
            if (!g) {
                g = k.rows[i].style.display != "none"
            }
            if (g) {
                if (k.rows[i].style.display != "none") {
                    k.rows[i].style.display = "none";
                    if (h) {
                        k.rows[i + 1].setAttribute("display", k.rows[i + 1].style.display);
                        k.rows[i + 1].style.display = "none"
                    }
                } else {
                    break
                }
            }
        }
        a.selectedIndex = Math.ceil((k.rows.length - 2) / d / PageSize) - 1;
        b[2].setAttribute("disabled", true);
        b[3].setAttribute("disabled", true)
    }
    b[0].setAttribute("disabled", false);
    b[1].setAttribute("disabled", false)
}
function getElementByTagName(b, a) {
    try {
        return b.getElementsByTagName(a)[0]
    } catch(c) {
    }
    return b.getElementsByTagName(a)
}
function OnPlayersLoaded(c) {
    var h;
    if (c) {
        h = window.frames[c.currentTarget.id].document
    } else {
        h = window.frames[window.event.srcElement.id].document
    }
    var f = getStatisticsTable(parseInt(h.getElementById("statisticstype").value));
    var e = parseInt(h.getElementById("recordid").value);
    var d = h.getElementById("tournamentid").value;
    for (i = f.rows.length - 3; i >= 0; i -= 2) {
        if (parseInt(f.rows[i].getAttribute("datakey_id")) == e) {
            var b = getElementByTagName(f.rows[i + 1].cells[1], "TABLE");
            for (j = b.rows.length - 3; j >= 0; j -= 2) {
                if (b.rows[j].getAttribute("datakey_id") == d) {
                    b.rows[j].setAttribute("loaded", true);
                    var g = getElementByTagName(b.rows[j + 1].cells[1], "a");
                    if (g) {
                        g.style.display = ""
                    }
                    getElementByTagName(b.rows[j + 1].cells[1], "div").innerHTML = h.getElementById("Content").innerHTML;
                    break
                }
            }
            break
        }
    }
    releaseRequest(c)
}
function ShowPlayers(f, g, l, b, c) {
    var m = getStatisticsTable(f);
    for (i = m.rows.length - 3; i >= 0; i -= 2) {
        if (parseInt(m.rows[i].getAttribute("datakey_id")) == g) {
            var d = getElementByTagName(m.rows[i + 1].cells[1], "TABLE");
            for (j = d.rows.length - 3; j >= 0; j -= 2) {
                if (d.rows[j].getAttribute("datakey_id") == l) {
                    if (!HasAttribute(d.rows[j], "loaded") || c) {
                        d.rows[j].setAttribute("loaded", false);
                        getElementByTagName(d.rows[j + 1].cells[1], "div").innerHTML = document.getElementById("updateProgress").innerHTML;
                        if (c) {
                            var k = getElementByTagName(d.rows[j + 1].cells[1], "a");
                            k.parentNode.removeChild(k)
                        }
                        var h = rootPath + "/TopShark/TournamentPlayers.aspx?type=" + f.toString() + "&id=" + g.toString() + "&pokernetwork=" + b.toString() + "&tournamentid=" + l + "&count=" + (c ? "0" : "40");
                        createRequest(h, OnPlayersLoaded, "OnPlayersLoaded(null)")
                    }
                    if (!c) {
                        var e = getElementByTagName(d.rows[j].cells[0], "IMG");
                        if (d.rows[j + 1].style.display != "none") {
                            e.src = rootPath + "/TopShark/TopSharkImages/collapsed.png";
                            e.alt = "Show Players";
                            d.rows[j + 1].style.display = "none";
                            d.insertRow(i + 2);
                            d.deleteRow(i + 2)
                        } else {
                            e.src = rootPath + "/TopShark/TopSharkImages/expanded.png";
                            e.alt = "Hide Players";
                            d.rows[j + 1].style.display = ""
                        }
                        e.title = e.alt
                    }
                    break
                }
            }
            break
        }
    }
}
function OnRemovePlayerComplete(a) {
    var b;
    if (a) {
        b = window.frames[a.currentTarget.id].document
    } else {
        b = window.frames[window.event.srcElement.id].document
    }
    releaseRequest(a)
}
function RemovePlayer(f) {
    for (statisticsType = 0; statisticsType <= 4; statisticsType++) {
        if (statisticsType != 3) {
            var d = getStatisticsTable(statisticsType);
            if (d) {
                for (i = d.rows.length - 3; i >= 0; i -= 2) {
                    if (parseInt(d.rows[i].getAttribute("datakey_id")) == f) {
                        d.deleteRow(i + 1);
                        d.deleteRow(i);
                        break
                    }
                }
                if (d.rows.length == 2) {
                    var c;
                    switch (statisticsType) {case 1:c = "MTT";break;case 2:c = "SNG";break;case 4:c = "HUP";break
                    }
                    var b = document.getElementById(c + "StatisticsViewEmptyGridView");
                    var a = document.getElementById(c + "StatisticsViewContent");
                    b.style.display = "";
                    a.innerHTML = "";
                    a.style.display = "none"
                }
                RestoreLayout(d)
            }
        }
    }
    var e = rootPath + "/TopShark/RemovePlayer.aspx?id=" + f.toString();
    createRequest(e, OnRemovePlayerComplete, "OnRemovePlayerComplete(null)")
}
function HideTournaments(c) {
    var b = document.getElementById(c);
    var a = document.getElementById(c.toString().replace("tournaments", "showLink"));
    if (b.style.display == "none") {
        a.innerHTML = "Hide Tournaments";
        b.style.display = ""
    } else {
        a.innerHTML = "Show Tournaments";
        b.style.display = "none"
    }
}
function ShowTournaments(h, l, o, e, f) {
    if (rootPath[rootPath.length - 1] == "/") {
        rootPath = rootPath.substr(0, rootPath.length - 1)
    }
    var p = getStatisticsTable(h);
    for (i = p.rows.length - 3; i >= 0; i -= 2) {
        if (parseInt(p.rows[i].getAttribute("datakey_id")) == l) {
            if (f) {
                p.rows[i].setAttribute("loaded", false);
                getElementByTagName(p.rows[i + 1].cells[1], "div").innerHTML = document.getElementById("updateProgress").innerHTML;
                var n = document.getElementById("loadLink_" + h + "_" + l);
                n.parentNode.removeChild(n);
                document.getElementById("showLink_" + h + "_" + l).innerHTML = "Hide Tournaments";
                var m = rootPath + "/TopShark/Tournaments.aspx?type=" + h.toString() + "&id=" + p.rows[i].getAttribute("datakey_id") + "&pokernetwork=" + p.rows[i].getAttribute("datakey_pokernetworkid") + "&playerid=" + p.rows[i].getAttribute("datakey_playerid") + "&count=0";
                if (HasAttribute(p.rows[i], "filter")) {
                    m += "&" + p.rows[i].getAttribute("filter")
                }
                createRequest(m, OnTournamentsLoaded, "OnTournamentsLoaded(null)")
            } else {
                var g = getElementByTagName(p.rows[i].cells[0], "IMG");
                var c = "graph_" + h + "_" + l;
                var k = document.getElementById(c);
                if (k.src.indexOf("loading")) {
                    var d = rootPath + "/Personalization/AsyncGraphController.ashx?id=" + e + "&pnid=" + o + "&tt=" + h + "&gt=4&w=900&h=300";
                    if (HasAttribute(p.rows[i], "filter")) {
                        d += "&" + p.rows[i].getAttribute("filter")
                    }
                    k.src = d;
                    var b = document.getElementById(c.toString().replace("graph", "link"));
                    b.href = k.src;
                    b.innerHTML = k.src.replace(/&gt/g, "&amp;gt")
                }
                if (p.rows[i + 1].style.display != "none") {
                    g.src = rootPath + "/TopShark/TopSharkImages/collapsed.png";
                    g.alt = "Show Tournaments";
                    p.rows[i + 1].style.display = "none";
                    p.insertRow(i + 2);
                    p.deleteRow(i + 2)
                } else {
                    g.src = rootPath + "/TopShark/TopSharkImages/expanded.png";
                    g.alt = "Hide Tournaments";
                    p.rows[i + 1].style.display = ""
                }
                g.title = g.alt
            }
            break
        }
    }
}
function HasAttribute(b, a) {
    try {
        if (b.getAttribute(a) == null) {
            return false
        }
        return b.hasAttribute(a)
    } catch(c) {
    }
    return true
}
function DateToString(a) {
    return(a.getMonth() + 1).toString() + "/" + a.getDate().toString() + "/" + a.getFullYear().toString()
}
function GetFilters() {
    var b = "";
    var c = document.getElementById(DateRangeDropDownList);
    var a = new Date();
    switch (parseInt(c.value)) {case 1:a.setDate(a.getDate() - 7);b += "&fromdate=" + DateToString(a);b += "&days=7";break;case 2:a.setDate(a.getDate() - 30);b += "&fromdate=" + DateToString(a);b += "&days=30";break;case 3:a.setDate(a.getDate() - 90);b += "&fromdate=" + DateToString(a);b += "&days=90";break;case 4:a.setDate(a.getDate() - 180);b += "&fromdate=" + DateToString(a);b += "&days=180";break;case 5:a.setDate(a.getDate() - 360);b += "&fromdate=" + DateToString(a);b += "&days=360";break;case 6:b += "&games=50";break;case 7:b += "&games=100";break;case 8:b += "&games=200";break;case 9:b += "&games=500";break;case 10:b += "&games=1000";break;case 11:b += "&games=2000";break;case -1:if (document.getElementById(StartDateTextBox).value.length > 0) {
        b += "&fromdate=" + document.getElementById(StartDateTextBox).value
    }if (document.getElementById(EndDateTextBox).value.length > 0) {
        b += "&todate=" + document.getElementById(EndDateTextBox).value
    }break
    }
    c = document.getElementById(GameTypeDropDownList);
    if (parseInt(c.value)) {
        b += "&poker=" + c.value
    }
    c = document.getElementById(LimitTypeDropDownList);
    if (parseInt(c.value)) {
        b += "&limit=" + c.value
    }
    c = document.getElementById(SpeedDropDownList);
    if (parseInt(c.value)) {
        b += "&speed=" + c.value
    }
    c = document.getElementById(EntrantsDropDownList);
    switch (parseInt(c.value)) {case 1:b += "&minplayers=2&maxplayers=4";break;case 2:b += "&minplayers=5&maxplayers=6";break;case 3:b += "&minplayers=7&maxplayers=9";break;case 4:b += "&minplayers=9&maxplayers=49";break;case 5:b += "&minplayers=50&maxplayers=90";break;case 6:b += "&minplayers=91&maxplayers=180";break;case 7:b += "&minplayers=181&maxplayers=499";break;case 8:b += "&minplayers=500&maxplayers=1999";break;case 9:b += "&minplayers=2000";break;case -1:if (document.getElementById(MinEntrantsTextBox).value.length > 0) {
        b += "&minplayers=" + document.getElementById(MinEntrantsTextBox).value
    }if (document.getElementById(MaxEntrantsTextBox).value.length > 0) {
        b += "&maxplayers=" + document.getElementById(MaxEntrantsTextBox).value
    }break
    }
    c = document.getElementById(BuyInDropDownList);
    switch (parseInt(c.value)) {case 1:b += "&maxbuyin=1.99";break;case 2:b += "&minbuyin=2.00&maxbuyin=6.99";break;case 3:b += "&minbuyin=7.00&maxbuyin=24.99";break;case 4:b += "&minbuyin=25.00&maxbuyin=59.99";break;case 5:b += "&minbuyin=60.00&maxbuyin=99.99";break;case 6:b += "&minbuyin=100.00";break;case -1:if (document.getElementById(MinBuyInTextBox).value.length > 0) {
        b += "&minbuyin=" + document.getElementById(MinBuyInTextBox).value
    }if (document.getElementById(MaxBuyInTextBox).value.length > 0) {
        b += "&maxbuyin=" + document.getElementById(MaxBuyInTextBox).value
    }break
    }
    return b
}
function FiltersCheckboxChanged() {
    if (document.getElementById("FiltersCheckbox").checked) {
        document.getElementById("filtersControl").style.display = ""
    } else {
        document.getElementById("filtersControl").style.display = "none"
    }
}
function OnTournamentsLoaded(d) {
    var g;
    if (d) {
        g = window.frames[d.currentTarget.id].document
    } else {
        g = window.frames[window.event.srcElement.id].document
    }
    var e = parseInt(g.getElementById("statisticstype").value);
    var b = getStatisticsTable(e);
    var c = parseInt(g.getElementById("recordid").value);
    for (i = b.rows.length - 3; i >= 0; i -= 2) {
        if (parseInt(b.rows[i].getAttribute("datakey_id")) == c) {
            b.rows[i].setAttribute("loaded", true);
            var f = document.getElementById("loadLink_" + e + "_" + c);
            if (f) {
                f.style.display = ""
            }
            getElementByTagName(b.rows[i + 1].cells[1], "div").innerHTML = g.getElementById("Content").innerHTML
        }
    }
    releaseRequest(d)
}
function DateRangeChanged() {
    if (document.getElementById(DateRangeDropDownList).value == "-1") {
        document.getElementById("CustomDateControl").style.display = ""
    } else {
        document.getElementById("CustomDateControl").style.display = "none";
        document.getElementById(StartDateTextBox).value = "";
        document.getElementById(EndDateTextBox).value = ""
    }
}
function BuyInChanged() {
    if (document.getElementById(BuyInDropDownList).value == "-1") {
        document.getElementById("CustomBuyInControl").style.display = ""
    } else {
        document.getElementById("CustomBuyInControl").style.display = "none"
    }
}
function EntrantsChanged() {
    if (document.getElementById(EntrantsDropDownList).value == "-1") {
        document.getElementById("CustomEntrantsControl").style.display = ""
    } else {
        document.getElementById("CustomEntrantsControl").style.display = "none"
    }
}
function Validate() {
    var a;
    a.text()
}
function LoadTournaments(a, c) {
    for (i = a.rows.length - 3; i >= 0; i -= 2) {
        if (!HasAttribute(a.rows[i], "loaded")) {
            a.rows[i].setAttribute("loaded", false);
            getElementByTagName(a.rows[i + 1].cells[1], "div").innerHTML = document.getElementById("updateProgress").innerHTML;
            var b = rootPath + "/TopShark/Tournaments.aspx?type=" + c.toString() + "&id=" + a.rows[i].getAttribute("datakey_id") + "&pokernetwork=" + a.rows[i].getAttribute("datakey_pokernetworkid") + "&playerid=" + a.rows[i].getAttribute("datakey_playerid") + "&count=40";
            if (HasAttribute(a.rows[i], "filter")) {
                b += "&" + a.rows[i].getAttribute("filter")
            }
            createRequest(b, OnTournamentsLoaded, "OnTournamentsLoaded(null)")
        }
    }
}
function OnStatisticsComplete(b) {
    var l;
    if (b) {
        l = window.frames[b.currentTarget.id].document
    } else {
        l = window.frames[window.event.srcElement.id].document
    }
    var k = parseInt(l.getElementById("statisticstype").value);
    var r;
    switch (k) {case 1:r = "MTT";break;case 2:r = "SNG";break;case 4:r = "HUP";break
    }
    var o = l.getElementById(r + "StatisticsGridView");
    var n = document.getElementById(r + "StatisticsGridView");
    var h = document.getElementById(r + "StatisticsViewEmptyGridView");
    var e = document.getElementById(r + "StatisticsViewContent");
    if (o) {
        var f = null;
        if (n) {
            var p = document.createElement("DIV");
            p.innerHTML = l.getElementById("Content").innerHTML;
            o = getElementByTagName(p, "TABLE");
            var m = last_datakey_id;
            for (i = 1; i < o.rows.length - 2; i += 2) {
                var a = parseInt(o.rows[i].getAttribute("datakey_id"));
                if (a > m) {
                    m = a
                }
                var d = false;
                for (j = 1; j < n.rows.length - 2; j += 2) {
                    if (parseInt(n.rows[j].getAttribute("datakey_id")) == a) {
                        d = true;
                        break
                    }
                }
                if (!d) {
                    var q = null;
                    if (document.all) {
                        q = n.insertRow(n.rows.length - 1);
                        q.mergeAttributes(o.rows[i]);
                        for (iCell = 0; iCell < o.rows[i].cells.length; iCell++) {
                            var g = q.insertCell();
                            g.mergeAttributes(o.rows[i].cells[iCell]);
                            g.innerHTML = o.rows[i].cells[iCell].innerHTML
                        }
                        q = n.insertRow(n.rows.length - 1);
                        q.mergeAttributes(o.rows[i + 1]);
                        for (iCell = 0; iCell < o.rows[i + 1].cells.length; iCell++) {
                            var g = q.insertCell();
                            g.mergeAttributes(o.rows[i + 1].cells[iCell]);
                            g.innerHTML = o.rows[i + 1].cells[iCell].innerHTML
                        }
                    } else {
                        q = n.insertRow(n.rows.length - 1);
                        q.innerHTML = o.rows[i].innerHTML;
                        q.className = o.rows[i].className;
                        q.setAttribute("datakey_id", o.rows[i].getAttribute("datakey_id"));
                        q.setAttribute("datakey_pokernetworkid", o.rows[i].getAttribute("datakey_pokernetworkid"));
                        q.setAttribute("datakey_playerid", o.rows[i].getAttribute("datakey_playerid"));
                        if (HasAttribute(o.rows[i], "filter")) {
                            q.setAttribute("filter", o.rows[i].getAttribute("filter"))
                        }
                        q = n.insertRow(n.rows.length - 1);
                        q.style.display = "none";
                        q.className = o.rows[i + 1].className;
                        q.innerHTML = o.rows[i + 1].innerHTML
                    }
                }
                RestoreLayout(n)
            }
            if (m > last_datakey_id) {
                last_datakey_id = m
            }
            for (i = 1; i < o.rows.length - 2; i += 2) {
                if (parseInt(o.rows[i].getAttribute("datakey_id")) == last_datakey_id) {
                    f = o.rows[i];
                    break
                }
            }
        } else {
            h.style.display = "none";
            e.innerHTML = l.getElementById("Content").innerHTML;
            e.style.display = "";
            if (o.rows.length > 1) {
                last_datakey_id = parseInt(o.rows[1].getAttribute("datakey_id"));
                f = o.rows[1]
            }
        }
        if (f != null) {
            if (f.cells.length > 1) {
                var c = f.cells[1].getElementsByTagName("a");
                if (c.length > 0) {
                    last_link = c[0].href
                }
            }
        }
        LoadTournaments(getElementByTagName(e, "TABLE"), k)
    } else {
        h.style.display = "";
        e.style.display = "none";
        e.innerHTML = ""
    }
    releaseRequest(b)
}
function updateStatistics(b, a) {
    if (b & 1) {
        url = rootPath + "/TopShark/Statistics.aspx?type=1" + (a ? "&refresh=1" : "");
        createRequest(url, OnStatisticsComplete, "OnStatisticsComplete(null)")
    }
    if (b & 2) {
        url = rootPath + "/TopShark/Statistics.aspx?type=2" + (a ? "&refresh=1" : "");
        createRequest(url, OnStatisticsComplete, "OnStatisticsComplete(null)")
    }
    if (b & 4) {
        url = rootPath + "/TopShark/Statistics.aspx?type=4" + (a ? "&refresh=1" : "");
        createRequest(url, OnStatisticsComplete, "OnStatisticsComplete(null)")
    }
}
;